<?php

    include 'sendquery_db.php';
    session_start();
    
    $id;
    $pw;
    
    if(isset($_GET["id"])){
        $id = $_GET["id"];
    }
    if(isset($_GET["pw"])){
        $pw = $_GET["pw"];
    }
    $success = false;
    
    $db = dbservice::getInstance();
    $result = $db->sendquery("select * from user where id='".$id."'");
    foreach($result as $row){
        if(strcmp($row["password"],$pw)==0){
            //print "login success";
            $name = $row["name"];
            $email = $row['email'];
            $picture = $row['picture'];
            
            $_SESSION["selab_login"] = "yes";
            $_SESSION["id"] = $id;
            $_SESSION["name"] = $name;
            $_SESSION["email"] = $email;
            $_SESSION["picture"] = $picture;
            $success = true;
        }
    }
    if($success){
        header( 'Location: ../page/cse326_main.php' ) ;    
    }else{
        var_dump($_GET);
        
    }
        
    
?>